package com.rm.zeyou.mapper;

import com.rm.zeyou.entity.Item;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.rm.zeyou.vo.response.SelectUserCollectionListResponseVo;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Update;

import java.math.BigDecimal;
import java.util.List;

/**
 * <p>
 * 服务项目表 Mapper 接口
 * </p>
 *
 * @author YanYang
 * @since 2025-03-12 15:55:08
 */
@Mapper
public interface ItemMapper extends BaseMapper<Item> {
    List<SelectUserCollectionListResponseVo> selectItemList();

    List<SelectUserCollectionListResponseVo> selectItemListByBachTid(@Param("itemIds") List<String> itemIds);

    List<SelectUserCollectionListResponseVo> selectUpgradeItemList(@Param("tid") Long tid, @Param("itemPrice") BigDecimal itemPrice);

    @Update("update t_item set real_sales_count = real_sales_count+#{orderNum} where id = #{itemId}")
    Integer updateSales(@Param("itemId") Long itemId, @Param("orderNum") Integer orderNum);

    @Update("update t_item set real_sales_count = real_sales_count - #{orderNum} where id = #{itemId} and real_sales_count >#{orderNum}")
    Integer subSales(@Param("itemId") Long itemId, @Param("orderNum") Integer orderNum);
}
